using System.Collections.Generic;
using SiemensAmd.Mmt.McisDbModel;
using SqlSugar;
using SqlSugarEx.Utilities;

namespace SiemensAmd.Mmt.McisDbDal
{
	public class ToolDataDal
	{
		private readonly SqlSugarClient _sqlSugar;

		public ToolDataDal(string server, string db, string user, string pwd)
		{
			this._sqlSugar = new SqlSugarClient(new ConnectionConfig
			{
				DbType = DbType.SqlServer,
				ConnectionString = DbUtility.SQLDbFormat(server, db, user, pwd),
				IsAutoCloseConnection = false
			});
		}

		public List<TOOLDATAEntity> QueryToolData(string nodeId, string container)
		{
			return this._sqlSugar.Queryable<TOOLDATAEntity>().WhereIF(!string.IsNullOrWhiteSpace(nodeId), (TOOLDATAEntity x) => x.NODEID == nodeId).WhereIF(!string.IsNullOrWhiteSpace(container), (TOOLDATAEntity x) => x.CONTAINERID == container)
				.ToList();
		}
	}
}
